package marmalius.item;

public class ItemTemplate {
	private int id;
	private String name;
	private int type;
	private boolean stackable;
	private int[] bonus;
	//private String description;
	//private double ShopValue; // ?
	//private double LowAlch; // ?
	//private double HighAlch; // ?
	
	public ItemTemplate(int id) {
		bonus = new int[12];
		for (int i = 0; i < 12; i++)
			bonus[i] = 0;
		this.id = id;
	}
	
	public int getId() { return id; }
	public int getClientId() { return id + 1; }
	public void setName(String name) { this.name = name; }
	public void setType(int type) { this.type = type; }
	public void setBonus(int index, int value) { bonus[index] = value; }
	public void setStackable(boolean stackable) { this.stackable = stackable; }
	public boolean isStackable() { return stackable; }
	public String getName() { return name; }
	public int getBonus(int index) { return bonus[index]; }
	public boolean isType(ItemType type) {
		return (this.type & type.getType()) == type.getType();
	}
	public ItemType getWearType() {
		if (isType(ItemType.BODY))
			return ItemType.BODY;
		if (isType(ItemType.LEGS))
			return ItemType.LEGS;
		if (isType(ItemType.FOOT))
			return ItemType.FOOT;
		if (isType(ItemType.HELM))
			return ItemType.HELM;
		if (isType(ItemType.GLOVE))
			return ItemType.GLOVE;
		if (isType(ItemType.HAND))
			return ItemType.HAND;
		if (isType(ItemType.SHIELD))
			return ItemType.SHIELD;
		if (isType(ItemType.CLOAK))
			return ItemType.CLOAK;
		if (isType(ItemType.ARROW))
			return ItemType.ARROW;
		if (isType(ItemType.NECK))
			return ItemType.NECK;
		if (isType(ItemType.RING))
			return ItemType.RING;
		return null;
	}
}